package test;

import scala.reflect.internal.TypeDebugging;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Random;

/**
 * <pre>
 * Created with IntelliJ IDEA.
 * User: zhengzhi
 * Date: 2017/3/29
 * To change this template use File | Settings | File Templates.
 * </pre>
 */
public class StringGenerate {


    private static FileWriter writer = null;
    /**
     * 生成指定长度的随机字符串,指定数量
     * @param length
     */
    public static String genRadomString(int length){
        String str = "aaaabbbbcccddddeeeffff";
        Random random = new Random();
        StringBuffer strBuff = new StringBuffer();

        for (int i = 0; i < length; i++) {
            int num = random.nextInt(16);
            strBuff.append(str.charAt(num));
        }

        return strBuff.toString();
    }


    public static void main(String[] args) throws IOException{
        int numbers = 20;
        File file = new File("D:/testData/sparkStrsTestData");
        writer = new FileWriter(file);

        while(numbers != 0){
            writer.write(genRadomString(5));
            writer.write(" ");

            numbers--;
            while (numbers%5 == 0)
                writer.write(System.getProperty("line.separator"));
        }

        writer.close();
        System.out.println("success!");

    }

}
